package com.robaone.gwt.hierarcialdb.client;

import com.robaone.gwt.hierarcialdb.client.state.StartState;
import com.robaone.gwt.hierarcialdb.client.ui.layout.AdminLayoutUi;
import com.robaone.gwt.hierarcialdb.shared.FieldVerifier;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Document;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class Hierarcialdbadmin implements EntryPoint {
	/**
	 * The message displayed to the user when the server cannot be reached or
	 * returns an error.
	 */
	public static final String SERVER_ERROR = "An error occurred while "
			+ "attempting to contact the server. Please check your network "
			+ "connection and try again.";

	private static AdminLayoutUi m_layout;
	/**
	 * Create a remote service proxy to talk to the server-side Greeting service.
	 */
	public static final HierarcialDBServiceAsync hdbService = GWT
			.create(HierarcialDBService.class);

	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {
		m_layout = new AdminLayoutUi();
		RootPanel.get().add(m_layout);
		StartState.go();
	}

	public static AdminLayoutUi getLayout() {
		return m_layout;
	}

	public static String getFileServletDownloadUrl(String id) {
		String url = Document.get().getElementById("_appsettings").getAttribute("filedownloadservleturl");
		url += id;
		return url;
	}

	public static String getFileServletUploadUrl(String id) {
		String url = Document.get().getElementById("_appsettings").getAttribute("fileuploadservleturl");
		url += id;
		return url;
	}
}
